<?php

namespace Cck\ArticlesSystem\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class TagStoreRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => [
                'required',
                'max:255',
                Rule::unique('tags', 'name')
            ],
            'slug' => [
                'max:255',
                'nullable',
                Rule::unique('tags', 'slug')->where('catalogue', $this->input('catalogue', ''))
            ],
            'catalogue' => [
                'max:255',
                'nullable',
                Rule::unique('tags', 'catalogue')->where('slug', $this->input('slug', ''))
            ],
            'recommend' => [
                'boolean'
            ],
            'seo_title' => 'max:255',
            'seo_keywords' => 'max:255',
            'seo_description' => 'max:255',
        ];
    }
}
